home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / TownMaze.lha / TownMaze / src.lzh / filllist.c < prev    next >
C/C++ Source or Header  |  1991-08-04  |  2KB  |  75 lines

  1. /*
  2. ** filllist.c  Copyright 1991 Kent Paul Dolan,
  3. **             Mountain View, CA, USA 94039-0755
  4. **
  5. ** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
  6. ** May be freely used or modified in any non-commercial work.  Copyrighted
  7. ** only to prevent patenting by someone else.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include "townmaze.h"
  12. #include "townproto.h"
  13.  
  14. #ifdef __STDC__
  15. void filllist()
  16. #else
  17. int filllist()
  18. #endif
  19. {
  20.   int i;
  21.  
  22. #if PROGRESS
  23.   fprintf(stderr,"Fill list ");
  24. #endif
  25.  
  26.  
  27. /*
  28. ** Everything starts in the isolated list; the others start empty.
  29. */
  30.  
  31.   isolated = 0;
  32.   live     = NOPOINTER;
  33.   dead     = NOPOINTER;
  34.   street   = NOPOINTER;
  35.   unused   = NOPOINTER;
  36.  
  37.   for (i = 0; i < listsize  - 1; i++)
  38.     statlist[i].next = i+1;
  39.   statlist[listsize -1].next = NOPOINTER;
  40.   for (i = 1; i < listsize; i++)
  41.     statlist[i].prev = i-1;
  42.   statlist[0].prev = NOPOINTER;
  43.   for (i = 0; i < listsize; i++)
  44.   {
  45.     statlist[i].status = ISOLATED;
  46.     statlist[i].streetnum = -1;
  47.     statlist[i].streetdir = -1;
  48.   }
  49.  
  50.   isolatedct = listsize;
  51.   livect     = 0;
  52.   deadct     = 0;
  53.   streetct   = 0;
  54.   unusedct   = 0;
  55.  
  56. /*
  57. ** Corner cells are too hard to use; get them off the list.
  58. */
  59.  
  60.   movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,0);
  61.   movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,
  62.              (mazewidth/2) - 1);
  63.   movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,
  64.              listsize-(mazewidth/2));
  65.   movefromto(&isolated,&isolatedct,&unused,&unusedct,UNUSED,listsize - 1);
  66.  
  67. /*
  68. ** There are no streets yet, so the streetnumct is zero too.
  69. */
  70.  
  71.   streetnumct = 0;
  72.  
  73.   return;
  74. }
  75.